package com.ruoyi.websocket.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.websocket.domain.WbNoticeMessage;
import com.ruoyi.websocket.service.IWbNoticeMessageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 通知信息框Controller
 * 
 * @author cpw
 * @date 2025-06-11
 */
@RestController
@RequestMapping("/WbNoticeMessage/WbNoticeMessage")
public class WbNoticeMessageController extends BaseController
{
    @Autowired
    private IWbNoticeMessageService wbNoticeMessageService;

    /**
     * 查询通知信息框列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(WbNoticeMessage wbNoticeMessage)
    {
        startPage();
        List<WbNoticeMessage> list = wbNoticeMessageService.selectWbNoticeMessageList(wbNoticeMessage);
        return getDataTable(list);
    }

    /**
     * 导出通知信息框列表
     */
    @PreAuthorize("@ss.hasPermi('WbNoticeMessage:WbNoticeMessage:export')")
    @Log(title = "通知信息框", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WbNoticeMessage wbNoticeMessage)
    {
        List<WbNoticeMessage> list = wbNoticeMessageService.selectWbNoticeMessageList(wbNoticeMessage);
        ExcelUtil<WbNoticeMessage> util = new ExcelUtil<WbNoticeMessage>(WbNoticeMessage.class);
        util.exportExcel(response, list, "通知信息框数据");
    }

    /**
     * 获取通知信息框详细信息
     */
    @PreAuthorize("@ss.hasPermi('WbNoticeMessage:WbNoticeMessage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wbNoticeMessageService.selectWbNoticeMessageById(id));
    }

    /**
     * 新增通知信息框
     */
    @PreAuthorize("@ss.hasPermi('WbNoticeMessage:WbNoticeMessage:add')")
    @Log(title = "通知信息框", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WbNoticeMessage wbNoticeMessage)
    {
        return toAjax(wbNoticeMessageService.insertWbNoticeMessage(wbNoticeMessage));
    }

    /**
     * 修改通知信息框
     */
    @PreAuthorize("@ss.hasPermi('WbNoticeMessage:WbNoticeMessage:edit')")
    @Log(title = "通知信息框", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WbNoticeMessage wbNoticeMessage)
    {
        return toAjax(wbNoticeMessageService.updateWbNoticeMessage(wbNoticeMessage));
    }

    /**
     * 删除通知信息框
     */
    @PreAuthorize("@ss.hasPermi('WbNoticeMessage:WbNoticeMessage:remove')")
    @Log(title = "通知信息框", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wbNoticeMessageService.deleteWbNoticeMessageByIds(ids));
    }

    /**
     * 消息设置为已读
     */
    @PutMapping("/updateReadStatus/{id}")
    public AjaxResult updateReadStatus(@PathVariable Long id)
    {
        return toAjax(wbNoticeMessageService.updateWbNoticeMessageReadStatus(id));
    }
}
